﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinForm
{
    public partial class ChiTietHoaDonNhapForm : Form
    {
        private Library.BIZ.HoaDonNhapBIZ hoadon;
        private List<Library.BIZ.ChiTietHoaDonNhapBIZ> listchitiet = new List<Library.BIZ.ChiTietHoaDonNhapBIZ>();
        private List<ChiTiet1> listchitiet1 = new List<ChiTiet1>();

        public ChiTietHoaDonNhapForm()
        {
            InitializeComponent();
        }

        public ChiTietHoaDonNhapForm(Library.BIZ.HoaDonNhapBIZ h)
        {
            InitializeComponent();
            this.hoadon = h;
        }

        private void ChiTietHoaDonNhapForm_Load(object sender, EventArgs e)
        {
            listchitiet = Library.DAL.ChiTietHoaDonNhapDAL.FindByHoaDon(hoadon);
            ChiTiet1 c;
            Library.BIZ.SanPhamBIZ sp;
            foreach (Library.BIZ.ChiTietHoaDonNhapBIZ i in listchitiet)
            {
                c = new ChiTiet1();
                c.IDSP = i.ID_SanPham;
                c.SoLuong = Int32.Parse(i.SoLuong.ToString());
                c.DonGia = long.Parse(i.DonGia.ToString());

                sp = new Library.BIZ.SanPhamBIZ(c.IDSP);

                c.TenSP = sp.TenSP;
                c.MaSP = sp.MaSP;

                listchitiet1.Add(c);

            }

            dataGridView1.DataSource = listchitiet1;
        }
    }

    class ChiTiet1
    {
        public int IDSP { get; set; }
        public string MaSP { get; set; }
        public string TenSP { get; set; }
        public int SoLuong { get; set; }
        public long DonGia { get; set; }
    }
}
